<div>
  <el-button @click='showAddCatDialog' type="success" plain>添加分类</el-button>
  <el-table :data="catList" style="width: 100%">
    <!-- 树的列
        file-icon="icon icon-file"
      folder-icon="icon icon-folder"
    -->
    <el-table-tree-column
      prop="cat_name"
      label="分类名称"
      width="220"
      tree-key="cat_id"
      parent-key="cat_pid"
      level-key="cat_level"
      :indent-size="30"
    ></el-table-tree-column>

    <!-- tree-key="cat_id  (找子节点)"
    parent-key="cat_pid"  (找父节点)
    level-key="cat_level"
    :indent-size="30" -->
    <!-- <el-table-column prop="cat_name" label="分类名称" width="180">
    </el-table-column> -->

    <el-table-column prop="cat_deleted" label="是否有效" width="180">
      <template slot-scope="scope">
        <span>{{ scope.row.cat_deleted ? '否' : '是' }}</span>
      </template>
    </el-table-column>
    <el-table-column prop="cat_level" label="层级">
      <template slot-scope="scope">
        <span v-if="scope.row.cat_level==0">一级</span>
        <span v-else-if="scope.row.cat_level==1">二级</span>
        <span v-else>三级</span>
      </template>
    </el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
          type="primary"
          size="mini"
          plain
          icon="el-icon-edit"
        ></el-button>
        <el-button
          type="danger"
          size="mini"
          plain
          icon="el-icon-delete"
        ></el-button>
      </template>
    </el-table-column>
  </el-table>

  <!-- 第一个对话框 : 添加分类对话框 -->
  <el-dialog title="添加分类" :visible.sync="dialogAddCatVisible">
    <el-form :model="addCatForm" label-width="100px">
      <el-form-item label="分类名称">
        <el-input v-model="addCatForm.cat_name"></el-input>
      </el-form-item>
      <el-form-item label="活动区域">
        <!-- 级联选择器 -->
        <!-- options : 提供数据 -->
        <!-- 默认识别 label 和 value 不识别 数组的 cat_name 和 cat_id -->
        <el-cascader :props='defaultProps'  v-model="addCatForm.cat_pid_arr" :options="options" change-on-select placeholder="请选择父级名称"></el-cascader>
        <!-- <el-select v-model="addCatForm.cat_pid_arr" placeholder="请选择父级名称">
          <el-option label="区域一" value="shanghai"></el-option>
          <el-option label="区域二" value="beijing"></el-option>
        </el-select> -->
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogAddCatVisible = false">取 消</el-button>
      <el-button type="primary" @click="addCat"
        >确 定</el-button
      >
    </div>
  </el-dialog>
</div>
